//
//  SecondHandTableViewCell.m
//  OneCreditTreasure
//
//  Created by iOS Grouper on 16/8/26.
//
//

#import "SecondHandTableViewCell.h"
#import "YYCycleScrollView.h"


@implementation SecondHandTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            [self creatView];
        }
    
    return self;
}
- (void)creatView{
    YYCycleScrollView *cycleScrollView = [[YYCycleScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 170 * AUTO_HEIGHT) animationDuration:2.0];
    [self addSubview:cycleScrollView];
    NSMutableArray *viewArray = [[NSMutableArray alloc] init];
    for (int i = 0; i < 5; i++) {
        UIImageView *tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenW,170 * AUTO_HEIGHT)];
        
        
        tempImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",i+1]];
        tempImageView.contentMode = UIViewContentModeScaleAspectFill;
        tempImageView.clipsToBounds = true;
        [viewArray addObject:tempImageView];
        cycleScrollView.backgroundColor = [UIColor redColor];
    }
    
    [cycleScrollView setFetchContentViewAtIndex:^UIView *(NSInteger(pageIndex)) {
        return [viewArray objectAtIndex:pageIndex];
    }];
    [cycleScrollView setTotalPagesCount:^NSInteger{
        return 5;
    }];
    [cycleScrollView setTapActionBlock:^(NSInteger(pageIndex)) {
        
        NSLog(@"点击的相关的页面%ld",(long)pageIndex);
        
    }];
    
    
    
    _titleL = [UILabel new];
    [self.contentView addSubview:_titleL];
    [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(cycleScrollView.mas_bottom).offset(10 * AUTO_HEIGHT);
        make.left.mas_equalTo(10 * AUTO_WIDTH);
        make.height.mas_equalTo(15 * AUTO_HEIGHT);
 
    }];
    _titleL.text = @"宝马x6";
    _titleL.textColor = ZITI;
    _titleL.font = [UIFont fontWithName:ZIXING size:15 * AUTO_HEIGHT];
    
    
    _dataL = [UILabel new];
    [self.contentView addSubview:_dataL];
    [_dataL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_titleL.mas_bottom).offset(10 * AUTO_HEIGHT);
        make.left.mas_equalTo(_titleL);
        make.height.mas_equalTo(_titleL);
        make.width.mas_equalTo(120 * AUTO_WIDTH);
    }];
    _dataL.text= @"2012-08-15上牌";
    _dataL.textColor = HS;
    _dataL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_WIDTH];
    
    //月供
    _mouthPriceL = [UILabel new];
    [self.contentView addSubview:_mouthPriceL];
    [_mouthPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_dataL.mas_bottom).offset(8 * AUTO_HEIGHT);
        make.left.height.mas_equalTo(_dataL);
        
        
    }];
    _mouthPriceL.textColor = HS;
    _mouthPriceL.text = @"月供3483元";
    _mouthPriceL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_HEIGHT];
    
    
    
    
    
    _longL = [UILabel new];
    [self.contentView addSubview:_longL];
    [_longL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_dataL);
        make.left.mas_equalTo(_dataL.mas_right).offset(20 * AUTO_WIDTH);
        make.height.mas_equalTo(_dataL);
        make.width.mas_equalTo(80 * AUTO_WIDTH);

    }];
    _longL.text = @"7.92公里";
    _longL.textColor = HS;
    _longL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_HEIGHT];
    
    
    
    //首付
    _firstPriceL = [UILabel new];
    [self.contentView addSubview:_firstPriceL];
    [_firstPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_mouthPriceL);
        make.left.height.mas_equalTo(_longL);
    
        
    }];
    _firstPriceL.text = @"首付2.85万";
    _firstPriceL.textColor = HS;
    _firstPriceL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_HEIGHT];
    
    
    
    _addressL = [UILabel new];
    [self.contentView addSubview:_addressL];
    [_addressL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_dataL);
        make.left.mas_equalTo(_longL.mas_right).offset(20 * AUTO_WIDTH);
        make.height.mas_equalTo(_dataL);
        
        
    }];
    _addressL.text = @"杭州";
    _addressL.textColor = HS;
    _addressL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_HEIGHT];
    
    
    
    //车价
    _totalPriceL = [UILabel new];
    [self.contentView addSubview:_totalPriceL];
    [_totalPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_firstPriceL);
        make.height.left.mas_equalTo(_addressL);
        
    }];
    _totalPriceL.text = @"车价14.3万";
    _totalPriceL.textColor = HS;
    _totalPriceL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_HEIGHT];
    
    
    
    
    


    }
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
